package jnpf.message.controller;

import com.alibaba.fastjson.JSONObject;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jnpf.base.ActionResult;
import jnpf.message.model.FlowEventMqPushVO;
import jnpf.message.projucer.FlowEventProducer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author  liuzhiqiang
 * @date 2024/11/13 16:18
 * @description: 流程事件处理
 */
@Slf4j
@Tag(name = "流程事件处理", description = "EventController")
@RestController
@RequestMapping("/api/workflow/event")
public class EventController {

    @Resource
    private FlowEventProducer flowEventProducer;

    @Operation(summary = "发送mq事件")
    @PostMapping("/hr/mq/push")
    public ActionResult<Map<String,Object>> info(@RequestBody FlowEventMqPushVO flowEventMqPushVO) {
        log.info("json--------------->:{}",JSONObject.toJSONString(flowEventMqPushVO));
        flowEventProducer.sendMessage(flowEventMqPushVO.getRoutingKey(),flowEventMqPushVO);
        return ActionResult.success();
    }
}
